//
//  MainTabBarController.m
//  HappyStore
//
//  Created by 点点充 on 16/1/18.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "MainTabBarController.h"
#import "industryClassificationVC.h"
#import "FriendViewController.h"

@interface MainTabBarController ()<UITabBarControllerDelegate>
{
    UIView *viewBack;
}
@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.delegate = self;
    
    
}

//实现UITabBarController代理方法
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    
//    NSString * str = [USER_DEFAULTS objectForKey:@"userid"];
//    点击发布
    if (viewController == self.viewControllers[2]) {
        if ([USER_DEFAULTS objectForKey:@"userid"] == nil) {
            //登录
            UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            UINavigationController *loginNAV = [LoginAndRegister instantiateViewControllerWithIdentifier:@"LoginNav"];
            [self presentViewController:loginNAV animated:YES completion:nil];
            return  NO;
        }
    
//        viewBack = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//        
//        viewBack.backgroundColor = [[UIColor colorWithWhite:0.6 alpha:1.0f] colorWithAlphaComponent:0.7];
//        
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(btnClickHidden)];
//        [viewBack addGestureRecognizer:tap];
//        [[[[UIApplication sharedApplication] windows] firstObject] addSubview:viewBack];
    }
    
    //点击我的时
    if (viewController == self.viewControllers[4]) {
        if ([USER_DEFAULTS objectForKey:@"userid"] == nil) {
            //登录
            UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            UINavigationController *loginNAV = [LoginAndRegister instantiateViewControllerWithIdentifier:@"LoginNav"];
            [self presentViewController:loginNAV animated:YES completion:nil];
            return  NO;
        }
    }
    

    return YES;
}

- (void)btnClickHidden
{
    viewBack.hidden = YES;
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
